package com.zhala.web.controller.system;

import com.zhala.common.annotation.Log;
import com.zhala.common.core.controller.BaseController;
import com.zhala.common.core.domain.CommonResult;
import com.zhala.common.core.domain.PageResult;
import com.zhala.common.enums.BusinessType;
import com.zhala.system.config.MaterialItem;
import com.zhala.system.domain.ZlSteelPlate;
import com.zhala.system.domain.vo.*;
import com.zhala.system.service.IZlSteelPlateService;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * 钢板相关接口
 *
 * @author ruoyi
 * @date 2024-11-11
 */
@RestController
@RequestMapping("/app/steel-plate")
public class AppZlSteelPlateController extends BaseController {
    @Autowired
    private IZlSteelPlateService zlSteelPlateService;


    /**
     * 钢板进场验收
     */
    @Log(title = "钢板进场验收", businessType = BusinessType.INSERT)
    @PostMapping("/acceptance")
    public CommonResult<Boolean> acceptance(@RequestBody @Valid SteelPlateAcceptanceReqVO reqVO) {
        return zlSteelPlateService.acceptance(reqVO);
    }


    /**
     * 钢板进场验收列表
     */
    @PostMapping("/page")
    public CommonResult<PageResult<List<ZlSteelPlate>>> page(@RequestBody SteelPlatePageReqVO pageReq) {
        PageResult<List<ZlSteelPlate>> page = zlSteelPlateService.page(pageReq);
        return CommonResult.success(page);
    }


    /**
     * 获取所有或未使用的钢板可指定材质筛选
     */
    @PostMapping("/list")
    @Parameter(name = "type", description = "类型1:获取所有未使用的钢板 0:获取所有", required = true)
    public CommonResult<List<ZlSteelPlate>> list(@RequestBody @Valid PlateListReqVO reqVO) {
        return zlSteelPlateService.list(reqVO);
    }


    /**
     * 钢板进场验详情
     */
    @GetMapping("/info")
    public CommonResult<ZlSteelPlate> info(@RequestParam("id") String id) {
        return zlSteelPlateService.detail(id);
    }

    @GetMapping("/delete")
    public CommonResult<Boolean> delete(@RequestParam("id") String id) {
        return zlSteelPlateService.deleteZlSteelPlateByID(id);
    }

    /**
     * 钢板统计
     */
    @PostMapping("/statistics")
    public CommonResult<List<PlateStatisticsRespVO>> statistics(@RequestBody StatisticsReqVO reqVO) {
        return zlSteelPlateService.statistics(reqVO);
    }

    /**
     * 获取钢板材质类型
     */
    @GetMapping("/materials")
    public CommonResult<List<MaterialItem>> materials() {
        return zlSteelPlateService.materials();
    }

   /**
     * 获取钢板批次号列表
     */
    @GetMapping("/batch-nums")
    public CommonResult<List<String>> listBatchNums() {
        return zlSteelPlateService.listBatchNums();
    }

    /**
     * 安装位置
     */
    @GetMapping("/install-location")
    public CommonResult<List<Map>> getInstallLocation() {
        return zlSteelPlateService.getInstallLocation();
    }


}
